package groep3.ssc.skaterViews;

import groep3.ssc.helpers.DataFunctions;
import groep3.ssc.main.R;
import groep3.ssc.model.Race;
import android.content.Context;
import android.content.res.Resources;
import android.widget.TextView;

public class TotalTimeView extends SkaterViewTemplate
{
    public TextView totalTime;

    public TotalTimeView(Context context)
    {
        super(context);
        totalTime = new SkaterTextView(context);
        addView(totalTime);
        subscribeToController();
    }

    @Override
    public void update(Race model)
    {
        Resources res = getResources();
        String timeAbbreviationString = res.getString(R.string.txtTimeAbbreviationString);
        this.totalTime.setText(timeAbbreviationString + " "
                + DataFunctions.longToFormattedTime(model.getSkater(model.getOurSkater()).getTotalTime()));
    }

    @Override
    public String toString()
    {
        Resources res = getResources();
        String txtTotalTime = res.getString(R.string.txtTotalTime);
        return txtTotalTime;
    }
}
